package com.ctvit.cch.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ctvit.cch.core.pojo.dto.hot.HotRecordFavoriteAddDTO;
import com.ctvit.cch.core.pojo.dto.hot.HotRecordFavoriteBatchAddDTO;
import com.ctvit.cch.core.service.IHotRecordFavoriteService;

import java.util.Arrays;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 热点数据收藏Controller
 *
 * @author heyingcheng
 * @date 2025/11/07
 */
@RestController
@RequestMapping("/hot/favorite")
public class HotRecordFavoriteController extends BaseController {

    private final IHotRecordFavoriteService hotFavoriteService;

    public HotRecordFavoriteController(IHotRecordFavoriteService hotFavoriteService) {
        this.hotFavoriteService = hotFavoriteService;
    }

    /**
     * 新增热点数据收藏
     */
    @PreAuthorize("@ss.hasPermi('hot:favorite:add')")
    @Log(title = "热点数据收藏", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody HotRecordFavoriteAddDTO dto) {
        return toAjax(hotFavoriteService.add(dto));
    }

    /**
     * 批量新增热点数据收藏
     */
    @PreAuthorize("@ss.hasPermi('hot:favorite:add')")
    @Log(title = "热点数据收藏", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public AjaxResult batchAdd(@RequestBody HotRecordFavoriteBatchAddDTO dto) {
        return toAjax(hotFavoriteService.batchAdd(dto));
    }

    /**
     * 删除热点数据收藏
     */
    @PreAuthorize("@ss.hasPermi('hot:favorite:remove')")
    @Log(title = "热点数据收藏", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody Long[] ids) {
        return toAjax(hotFavoriteService.removeBatchByIds(Arrays.asList(ids)));
    }

}